// components/func-item/index.js
import {api} from '../../js/util';
const app = getApp();
const componentBehavior = require('../../js/common/ComponentBehavior')

Component({
  externalClasses:['icon'],
  /**
   * 组件的属性列表
   */
  properties: {
    hasTitle:{
      type:Boolean,
      value:true
    },
    title:{
      type:String,
      value:''
    },
    moreText: {
      type: String,
      value: ''
    },
    column:{
      type:Number,
      value:4
    },
    funList:{
      type:Array,
      value:[]
    },
    moreLink:{
      type:String,
      value:''
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    iconColor:""
  },
  attached:function(){
    this.setData({
      iconColor:api.titleColor||"#e56b14"
    })
  },
  behaviors: [componentBehavior],
  /**
   * 组件的方法列表
   */
  methods: {
    onClickItem:function(e){
      let url = e.currentTarget.dataset.url;
      if(url.indexOf('indexShowDialog')>-1){
        let index = url.lastIndexOf('=');
        let string = url.substring(index+1,url.length);
        if(string=='true'){
          app.globalData.indexShowDialog = true;
        }else{
          app.globalData.indexShowDialog = false;
        }
        wx.switchTab({ url: url });
      }else{
        this.triggerEvent("onClickItem", url);
      }
    }
  }
})
